%%%%%%%%%%%
% fit_mar.m
%%%%%%%%%%%

Full_Data = Data;

dimension = size(Data{1}, 1);

N = length(Data);

% Data comes in as N x 1 cell array:
% each cell is a d x T matrix (T - variable)

for dim=1:dimension
  clear Data;

  for n = 1:N
    x = Full_Data{n};

    % Extract this dimension only
    Data{n} = x(dim,:);
  end

  fit_ar;

  eval(sprintf('ar_order_%d = ar_order;', dim));
  eval(sprintf('ar_coeffs_%d = ar_coeffs;', dim));
  eval(sprintf('ar_norm_%d = ar_norm;', dim));
  eval(sprintf('ar_mean_%d = ar_mean;', dim));
  eval(sprintf('ar_precision_%d = ar_precision;', dim));
end

